$OpenBSD: patch-tests_regression-test_py,v 1.1 2016/05/01 20:23:54 danj Exp $
--- tests/regression-test.py.orig	Wed Mar  2 15:06:44 2016
+++ tests/regression-test.py	Sun May  1 19:58:24 2016
@@ -490,7 +490,7 @@ def findContribSql(filename):
 
     # Try to get base dir for postgres contrib
     try:
-        postgis_base_dir = os.popen('pg_config | grep -m 1 "^INCLUDEDIR ="').read().strip().split(' ')[2].split('/include')[0]
+        postgis_base_dir = os.popen('pg_config | grep "^INCLUDEDIR =" |head -n1').read().strip().split(' ')[2].split('/include')[0]
     except:
         postgis_base_dir = '/usr'
 
@@ -550,6 +550,9 @@ def setupDB():
             global created_tablespace
             created_tablespace = 0
 
+            subprocess.call(["/bin/rm", "-rf", "/tmp/psql-tablespace"])
+            os.makedirs("/tmp/psql-tablespace")
+            test_cur.execute("""CREATE TABLESPACE tablespacetest LOCATION '/tmp/psql-tablespace'""")
             test_cur.execute("""SELECT spcname FROM pg_tablespace WHERE spcname = 'tablespacetest'""")
             if test_cur.fetchone():
                 print "We already have a tablespace, can use that"
@@ -609,7 +612,7 @@ def tearDownDB():
     gen_cur.close()
     gen_conn.close()
     if (created_tablespace == 1):
-        returncode = subprocess.call(["/usr/bin/sudo", "/bin/rmdir", "/tmp/psql-tablespace"])
+        returncode = subprocess.call(["/bin/rm", "-rf", "/tmp/psql-tablespace"])
 
 
 if __name__ == "__main__":
